package com.tenton.service.Impl;

import com.tenton.mapper.PositionMapper;
import com.tenton.pojo.Position;
import com.tenton.service.PositionService;
import com.tenton.utils.MybatisUtils;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

/**
 * @Date: 2021/1/13
 * @Author: Tenton
 * @Description:
 */
public class PositionServiceImpl implements PositionService {
    /**
     * 增加职位信息
     * @param position
     * @return
     */
    @Override
    public int insertPosition(Position position) {
        SqlSession sqlSession = MybatisUtils.getSqlSession(true);
        PositionMapper mapper = sqlSession.getMapper(PositionMapper.class);
        int result = mapper.insertPosition(position);
        return result;
    }

    /**
     * 删除职位信息
     * @param id
     * @return
     */
    @Override
    public int deletePosition(int id) {
        SqlSession sqlSession = MybatisUtils.getSqlSession(true);
        PositionMapper mapper = sqlSession.getMapper(PositionMapper.class);
        int result = mapper.deletePosition(id);
        return result;
    }
    /**
     * 修改职位信息
     * @param position
     * @return
     */
    @Override
    public boolean updatePosition(Position position) {
        SqlSession sqlSession = MybatisUtils.getSqlSession(true);
        PositionMapper mapper = sqlSession.getMapper(PositionMapper.class);
        boolean b = mapper.updatePosition(position);
        return b;
    }
    /**
     * 查询所有用户信息
     * @return
     */
    @Override
    public List<Position> listPosition() {
        SqlSession sqlSession = MybatisUtils.getSqlSession();
        PositionMapper mapper = sqlSession.getMapper(PositionMapper.class);
        List<Position> positions = mapper.listPosition();
        return positions;
    }
}
